package com.zues.samples.model;

import java.io.Serializable;
import java.sql.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

@Entity
@Table(name = "exam_user")
public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7477737996138940102L;

	// ID
	@Id
	@Column(name = "user_id", nullable = false)
	private String userID;

	// 名字
	@Column(name = "user_name", nullable = false)
	private String userName;

	// 密码
	@Column(name = "password", nullable = false)
	private String password;

	// 电话
	@Column(name = "tel")
	private String tel;

	// 邮箱
	@Column(name = "email")
	private String email;

	// 地址
	@Column(name = "address")
	private String address;

	// 生日
	@Column(name = "birthday", nullable = false)
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date birthday;

	// 性别
	@Column(name = "gender", nullable = false)
	private int gender;

	// 最后状态时间
	@Column(name = "last_lock_time")
	private java.util.Date lastLockTime;

	// 登录失败次数
	@Column(name = "login_fail_count")
	private Integer loginFailCount;
	
	private Integer role;

	@OneToMany(mappedBy = "user", fetch = FetchType.EAGER)
	private Set<UserSubject> userSubject;


	@OneToMany(mappedBy = "user", fetch = FetchType.EAGER)
	private Set<Score> score;
	// getter AND setter
	
	public String getUserID() {
		return userID;
	}

	public Set<Score> getScore() {
		return score;
	}

	public void setScore(Set<Score> score) {
		this.score = score;
	}

	public void setUserID(String userID) {
		this.userID = userID;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public java.util.Date getLastLockTime() {
		return lastLockTime;
	}

	public void setLastLockTime(java.util.Date lastLockTime) {
		this.lastLockTime = lastLockTime;
	}

	public Integer getLoginFailCount() {
		return loginFailCount;
	}

	public void setLoginFailCount(Integer loginFailCount) {
		this.loginFailCount = loginFailCount;
	}

	public Set<UserSubject> getUserSubject() {
		return userSubject;
	}

	public void setUserSubject(Set<UserSubject> userSubject) {
		this.userSubject = userSubject;
	}

	
	public Integer getRole() {
		return role;
	}

	public void setRole(Integer role) {
		this.role = role;
	}

	@Override
	public String toString() {
		return "User [userID=" + userID + ", userName=" + userName + ", password=" + password + ", tel=" + tel
				+ ", email=" + email + ", address=" + address + ", birthday=" + birthday + ", gender=" + gender
				+ ", lastLockTime=" + lastLockTime + ", loginFailCount=" + loginFailCount + ", userSubject="
				+ userSubject + "]";
	}

	
}
